<template>
  <div class="header-crumb">
    <el-breadcrumb separator-icon="CaretRight">
      <template v-for="breadcrumb in breadcrumbs" :key="breadcrumb.path">
        <el-breadcrumb-item :to="{ path: breadcrumb.path }">
          {{ breadcrumb.name }}
        </el-breadcrumb-item>
      </template>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
import { useRoute } from 'vue-router';
import { useLoginStore } from '@/store/login';
import { mapPathToBreadcrumb } from '@/utils/map-menus';
import { computed } from 'vue';

const route = useRoute();
const userMenus = useLoginStore().userMenus;
const breadcrumbs = computed(() => {
  return mapPathToBreadcrumb(route.path, userMenus);
});
</script>

<style scoped lang="scss">
.header-crumb {
}
</style>
